{% extends 'base.html' %}

{# 通用的表单提交页面，需要4个信息——form_title, form, btn_text, redirect_url #}

{% block title %}
    {{ form_title }}
{% endblock %}

{% block content %}
<div class="container">
    <div class="row">
        <div class="col-xs-10 col-xs-offset-1 col-sm-6 col-sm-offset-3 col-md-4 col-md-offset-4">
            <div class="panel panel-default">
                <div class="panel-heading">
                <h3 class="panel-title">{{ form_title }}</h3>
                </div>
                <div class="panel-body">
                <form action="" method="POST" id="form">
                    {% csrf_token %}
                    {% for field in form %}
                        <div class="form-group">
                            <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                            {{ field }}
                            <p class="text-danger">{{ field.errors.as_text }}</p>
                        </div>
                    {% endfor %}
                    <span class="pull-left text-danger" id="tip">{{ form.non_field_errors }}</span>
                    <div class="clearfix"></div>
                    {% block other_buttons %}{% endblock %}
                    <div class="pull-right">
                        <input id="form_submit_btn" class="btn btn-primary" type="submit" value="{{ btn_text }}">
                        <input class="btn btn-default" type="button" value="返回" onclick="window.location.href='{{ redirect_url }}'">
                    </div>
                </form>
                </div>
            </div>
        </div>
    </div>
</div>

{% endblock %}